home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / tokenizeList.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.4 KB  |  85 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Jul 2, 1998
  22. //<doc>
  23. //<name tokenizeList>
  24. //<owner "Alias|Wavefront Unsupported">
  25. //
  26. //<synopsis>
  27. //        int tokenizeList( string $list, string $tokenizedList[] )
  28. //
  29. //<description>
  30. //        Takes a string $list representing a list of items.  The 
  31. //        items can be either whitespace- or comma-separated.
  32. //        The individual items in the list are returned as elements
  33. //        of the result array, stored in $tokenizedList.  
  34. //
  35. //<flags>
  36. //        string $list The string of values to tokenize.  Separated by
  37. //        either whitespace or commas.  
  38. //        string[]    $tokenizedList    The items in $list, after tokenization
  39. //
  40. //<examples>
  41. //  string $list = "1 6 7, 54";
  42. //  string $tokenizedList[];
  43. //  tokenizeList($list, $tokenizedList);
  44. //  // Result : 1 //
  45. //  print $tokenizedList;
  46. //  <i>1</i>
  47. //  <i>6</i>
  48. //  <i>7</i>
  49. //  <i>54</i>
  50. //                
  51. //<returns>
  52. //        int : 1 if successful, 0 if unsuccessful
  53. //
  54. //</doc>
  55. //
  56. global proc int tokenizeList( string $list, string $tokenizedList[] )
  57. {
  58.     string $regExpr          = ",";
  59.     string $replaceWith     = " ";
  60.     string $substitutedList = "";
  61.     
  62.     // Remove the commas, if any, and replace them with spaces
  63.     //
  64.     while( $substitutedList != $list ) {
  65.         // Do this only after the first time.
  66.         //
  67.         if( $substitutedList != "" ) {
  68.             $list = $substitutedList;
  69.         }
  70.  
  71.         $substitutedList = `substitute $regExpr $list $replaceWith`;
  72.     }
  73.     
  74.     // Check if $llist is empty.
  75.     //
  76.     if( size( $list ) == 0 ) {
  77.         return 0;
  78.     }
  79.     
  80.     tokenize( $list, $tokenizedList );
  81.  
  82.     return 1;
  83. }
  84.  
  85.